package com.demarc.pesquisas.negocio.entidade.entrevistador;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import com.demarc.pesquisas.negocio.entidade.AbstractPessoa;

@Entity
@Table(name = "etr_entrevistador")
@AttributeOverrides(value = {
		@AttributeOverride(name = "nome", column = @Column(name = "etr_nome", nullable = false)),
		@AttributeOverride(name = "cpf", column = @Column(name = "etr_cpf", nullable = false)),
		@AttributeOverride(name = "rg", column = @Column(name = "etr_rg", nullable = false)),
		@AttributeOverride(name = "orgaoExpedidor", column = @Column(name = "etr_orgao_expedidor", nullable = false)),
		@AttributeOverride(name = "telefone", column = @Column(name = "etr_telefone")),
		@AttributeOverride(name = "telefoneAuxiliar", column = @Column(name = "etr_telefone_auxiliar")),
		@AttributeOverride(name = "celular", column = @Column(name = "etr_celular")),
		@AttributeOverride(name = "celularAuxiliar", column = @Column(name = "etr_celular_auxiliar")),
		@AttributeOverride(name = "ultimaAtualizacao", column = @Column(name = "etr_ultima_atualizacao")),
		@AttributeOverride(name = "usuarioAtualizacao", column = @Column(name = "etr_usuario_atualizacao")) })
public class Entrevistador extends AbstractPessoa<Long> {

	public static final String ID = "etr_id";

	private Long id;

	@Id
	@Column(name = ID)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(super.getCpf()).toHashCode();
	}

	@Override
	public boolean equals(Object obj) {
		boolean isEquals = false;

		if (obj == this) {
			isEquals = true;
		} else if (obj instanceof Entrevistador) {
			Entrevistador entrevistador = (Entrevistador) obj;
			isEquals = new EqualsBuilder().append(super.getCpf(),
					entrevistador.getCpf()).isEquals();
		}
		return isEquals;
	}
}
